home *** CD-ROM | disk | FTP | other *** search
/ Into His Marvelous Light / Into His Marvelous LIGHT.iso / lesson1.dxr / 00274_Script_Rollover Cursor Change < prev    next >
Text File  |  2001-09-05  |  7KB  |  258 lines

  1. -- DESCRIPTION --
  2.  
  3. on getBehaviorDescription
  4.   return"¼
  5. ROLLOVER CURSOR CHANGE"&RETURN&RETURN&"¼
  6. Changes the cursor when the mouse rolls over the current sprite. ¼
  7. Choose one of the pointers included with Director, ¼
  8. or specify two 1-bit 16x16 pixel bitmap members: ¼
  9. one to act as the pointer image, ¼
  10. the other to define the transparent/opaque areas of the cursor."&RETURN&RETURN&"¼
  11. TIPS:"&RETURN&"¼
  12. Place a single pixel at the topRight and bottomLeft of the image itself to ¼
  13. create what is in fact a 17x17 pixel bitmap.  ¼
  14. These extra pixels will not appear in the cursor (they will be clipped) ¼
  15. but the mask will align with them.  This ensures that the opaque area ¼
  16. surrounds the cursor image correctly."&RETURN&RETURN&"¼
  17. Set the regPoint of the image to define the cursor's hotspot."&RETURN&RETURN&"¼
  18. PARAMETERS:"&RETURN&"¼
  19. * EITHER - Use one of Director's built-in cursors."&RETURN&RETURN&"¼
  20. * OR - Check button to use your own bitmap images."&RETURN&"¼
  21. * Custom Image " &RETURN&"¼
  22. * Custom Mask"&RETURN&RETURN&"¼
  23. To use custom images, ensure that the check button is on."
  24. end getBehaviorDescription
  25.  
  26.  
  27. on getBehaviorTooltip me
  28.   return "¼
  29. Use with graphic sprites."&RETURN&RETURN&"¼
  30. Modify the cursor when the"&RETURN&"¼
  31. mouse rolls over the sprite."&RETURN&"¼
  32. Use built-in or custom images."
  33. end getBehaviorTooltip
  34.  
  35.  
  36.  
  37. -- PROPERTIES --
  38.  
  39. property spriteNum
  40. -- author-defined parameters
  41. property myCursorType
  42. property myBuiltInCursor
  43. property myCursorMember
  44. property myCustomCursor
  45. property myCustomMask
  46. -- internal properties
  47. property mySprite
  48. property mySavedCursor
  49.  
  50.  
  51. -- EVENT HANDLERS --
  52.  
  53. on beginSprite me
  54.   SetSpriteCursor me
  55. end beginSprite
  56.  
  57.  
  58. on endSprite me
  59.   mySprite.cursor = mySavedCursor
  60. end endSprite
  61.  
  62.  
  63.  
  64. -- CUSTOM HANDLER --
  65.  
  66. on SetSpriteCursor me
  67.   if spriteNum < 1 then
  68.     if the runMode = "Author" then
  69.       ErrorAlert me
  70.     end if
  71.   end if
  72.   
  73.   mySprite = sprite (me.spriteNum)
  74.   -- Save cursor to revert to
  75.   mySavedCursor = mySprite.cursor
  76.   
  77.   -- Set the cursor of the sprite
  78.   if voidP (myCursorType) then
  79.     mySprite.cursor = myBuiltInCursor
  80.     exit
  81.   end if
  82.   
  83.   case myCursorType of
  84.     "Built-in cursor":
  85.       mySprite.cursor = myBuiltInCursor
  86.     "Cursor member":
  87.       myCursorMember = value (myCursorMember) 
  88.       cursorList = [myCursorMember.number]
  89.       mySprite.cursor = cursorList
  90.     "1 bit bitmap":
  91.       myCustomCursor = value (myCustomCursor) 
  92.       cursorList = [myCustomCursor.number]
  93.       if myCustomMask <> "no mask" then
  94.         myCustomMask = value (myCustomMask) 
  95.         cursorList.append(myCustomMask.number)
  96.       end if
  97.       mySprite.cursor = cursorList
  98.   end case
  99. end SetSpriteCursor
  100.  
  101.  
  102.  
  103. -- ERROR CHECKING --
  104.  
  105. on ErrorAlert me
  106.   -- sent by SetSpriteCursor
  107.   -- Determine the behavior's name
  108.   behaviorName = string (me)
  109.   delete word 1 of behaviorName
  110.   delete the last word of behaviorName
  111.   delete the last word of behaviorName
  112.   
  113.   alert "¼
  114. BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¼
  115. Behavior "&behaviorName&"has been attached to the frame."&RETURN&RETURN&"¼
  116. It will have no effect, and should be removed from the behavior channel."
  117. end ErrorAlert
  118.  
  119.  
  120.  
  121. -- AUTHOR-DEFINED PARAMETERS --
  122.  
  123. on getPropertyDescriptionList me
  124.   
  125.   if not the currentSpriteNum then exit
  126.   
  127.   propertyDescriptionList = [:]
  128.   cursorTypes = []
  129.   cursorMembersList = GetCursorMembers (me)
  130.   cursorBitmapsList = GetCursorBitmaps (me)
  131.   cursorMasksList = duplicate (cursorBitmapsList)
  132.   cursorMasksList.addAt (1, "no mask")
  133.   
  134.   cursorMembers = cursorMembersList.count()
  135.   bitmapCursors = cursorBitmapsList.count()
  136.   if cursorMembers then
  137.     cursorTypes.append ("Cursor member")
  138.   end if
  139.   if bitmapCursors then
  140.     cursorTypes.append ("1 bit bitmap")
  141.   end if
  142.   if cursorTypes.count() then
  143.     cursorTypes.addAt (1, "Built-in cursor")
  144.     propertyDescriptionList.addProp ¼
  145. ( ¼
  146.  #myCursorType, ¼
  147.  [¼
  148.   #comment: "CHOICE OF TYPE - Use which type of cursor?", ¼
  149.   #format:  #string, ¼
  150.   #range:    cursorTypes, ¼
  151.   #default:  cursorTypes[1]¼
  152.  ] ¼
  153. )
  154.     
  155.     propertyDescriptionList.addProp ¼
  156. ( ¼
  157.  #myBuiltInCursor, ¼
  158.  [¼
  159.   #comment: "CHOICE OF CURSOR   -               Built-in cursor:", ¼
  160.   #format:  #cursor, ¼
  161.   #default:  280¼
  162.  ] ¼
  163. )
  164.   else
  165.     return ¼
  166. [ ¼
  167.  #myBuiltInCursor: ¼
  168.  [¼
  169.   #comment: "Use which cursor?", ¼
  170.   #format:  #cursor, ¼
  171.   #default:  280¼
  172.  ] ¼
  173. ]
  174.   end if
  175.   
  176.   if cursorMembers then
  177.     propertyDescriptionList.addProp ¼
  178. ( ¼
  179.   #myCursorMember, ¼
  180.  [¼
  181.   #comment: "-             Cursor member:", ¼
  182.   #format:  #member, ¼
  183.   #range:    cursorMembersList, ¼
  184.   #default:  cursorMembersList[1] ¼
  185.  ] ¼
  186. )
  187.   end if
  188.   
  189.   if bitmapCursors then
  190.     propertyDescriptionList.addProp ¼
  191. ( ¼
  192.  #myCustomCursor, ¼
  193.  [ ¼
  194.   #comment: "-   1 bit bitmap (image):", ¼
  195.   #format:  #bitmap, ¼
  196.   #range:    cursorBitmapsList, ¼
  197.   #default:  cursorBitmapsList[1]¼
  198.  ] ¼
  199. )
  200.     
  201.     propertyDescriptionList.addProp ¼
  202. ( ¼
  203.  #myCustomMask, ¼
  204.  [ ¼
  205.   #comment: "1 bit bitmap   (mask):", ¼
  206.   #format:  #bitmap, ¼
  207.   #range:    cursorMasksList, ¼
  208.   #default:  cursorMasksList[1]¼
  209.  ] ¼
  210. )    
  211.   end if
  212.   
  213.   return propertyDescriptionList
  214. end
  215.  
  216.  
  217. on GetCursorMembers me
  218.   cursorMembersList = []
  219.   maxCastLib = the number of castLibs
  220.   repeat with theCastLib = 1 to maxCastLib
  221.     maxMember = the number of members of castLib theCastLib
  222.     repeat with memberNumber = 1 to maxMember
  223.       theMember = member(memberNumber, theCastLib)
  224.       if theMember.type = #cursor then
  225.         if theMember.name = EMPTY then
  226.           cursorMembersList.append(theMember)
  227.         else
  228.           cursorMembersList.append(theMember.name)
  229.         end if
  230.       end if
  231.     end repeat
  232.   end repeat
  233.   return cursorMembersList
  234. end GetCursorMembers
  235.  
  236.  
  237. on GetCursorBitmaps me
  238.   cursorBitmapsList = []
  239.   maxCastLib = the number of castLibs
  240.   repeat with theCastLib = 1 to maxCastLib
  241.     maxMember = the number of members of castLib theCastLib
  242.     repeat with memberNumber = 1 to maxMember
  243.       theMember = member(memberNumber, theCastLib)
  244.       if theMember.type = #bitmap then
  245.         if theMember.depth > 1 then next repeat
  246.         if theMember.width > 20 then next repeat
  247.         if theMember.height > 20 then next repeat
  248.         
  249.         if theMember.name = EMPTY then
  250.           cursorBitmapsList.append(theMember)
  251.         else
  252.           cursorBitmapsList.append(theMember.name)
  253.         end if
  254.       end if
  255.     end repeat
  256.   end repeat
  257.   return cursorBitmapsList
  258. end GetCursorMembers